package golang

import (
	"strings"
	"text/template"

	"github.com/gogo/protobuf/protoc-gen-gogo/generator"
)

var TemplateFunc = template.FuncMap{
	"CamelCase":        generator.CamelCase,
	"CamelCaseSlice":   generator.CamelCaseSlice,
	"SplitPackageName": SplitPackageName,
	"SplitType":        SplitType,
}

func SplitPackageName(t string) (packageName string) {
	words := strings.Split(t, ".")
	if len(words) == 2 {
		packageName = words[0]
	}
	return
}

func SplitType(t string) (tYpE string) {
	words := strings.Split(t, ".")
	if len(words) == 2 {
		tYpE = words[1]
	}
	return
}

//func IsGoBaseType(t string) bool {
//	switch t {
//	case "int", "uint", "int32", "uint32", "int64", "uint64", "int8", "uint8", "int16", "uint16",
//		"string", "bool",
//		"double", "float32", "float64":
//		return true
//	}
//	return false
//}
